<script setup>

import { computed } from 'vue'
import {router} from '../router/index.js'

import {useRoute} from "vue-router";


import {
  Menu as ElIconMenu,
  Monitor as ElIconMonitor,
  FirstAidKit as ElIconFirstAidKit,
  ShoppingCart as ElIconShoppingCart,
  Document as ElIconDocument,
  DataLine as ElIconDataLine,
  Setting as ElIconSetting,
} from '@element-plus/icons-vue'
import {userStore} from "@/store/index.js";

const store = userStore();
const hasPermission = (code) => {
  return store.permissions.includes(code);
}

// v-if="hasPermission('system:logList')"

const route = useRoute();
const activeMenu = computed(() => route.path)
const toCategory=()=>{
  router.push('/column')
}
</script>

<template>
  <el-aside width="200px" class="side-bar">
    <el-menu
        :default-active="activeMenu"
        class="el-menu-vertical"
        background-color="#001529"
        text-color="#fff"
        active-text-color="#ffd04b"
        router
    >
      <el-menu-item index="/dashboard">
        <el-icon><el-icon-menu /></el-icon>
        <span>系统首页</span>
      </el-menu-item>

      <el-sub-menu index="1">
        <template #title>
          <el-icon><el-icon-monitor /></el-icon>
          <span>运动健康</span>
        </template>
        <el-menu-item index="/sports/data">数据查询</el-menu-item>
        <el-menu-item index="/sports/plan">数据分析</el-menu-item>
      </el-sub-menu>

      <el-sub-menu index="2">
        <template #title>
          <el-icon><el-icon-first-aid-kit /></el-icon>
          <span>医疗服务</span>
        </template>
        <el-menu-item index="/departmentManagement">科室管理</el-menu-item>
        <el-menu-item index="/hospital">医院管理</el-menu-item>
        <el-menu-item index="/doctor">医生管理</el-menu-item>
        <el-menu-item index="/disease">疾病管理</el-menu-item>
        <el-menu-item index="/appointmentSetting">预约设置</el-menu-item>
        <el-menu-item index="/appointmentQuery">预约查询</el-menu-item>
        <el-menu-item index="/registrationOrder">挂号订单</el-menu-item>
        <el-menu-item index="/viewportmentQuery">体检订单</el-menu-item>
      </el-sub-menu>

      <el-sub-menu index="3">
        <template #title>
          <el-icon><el-icon-shopping-cart /></el-icon>
          <span>商城管理</span>
        </template>
        <el-menu-item index="/category">品类管理</el-menu-item>
        <el-menu-item index="/productManagement">商品管理</el-menu-item>
        <el-menu-item index="/orderManagement">订单管理</el-menu-item>
        <el-menu-item index="/afterSalesService">售后服务</el-menu-item>
        <el-menu-item index="/shippingTemplate">运费模板</el-menu-item>
      </el-sub-menu>

      <el-sub-menu index="4">
        <template #title>
          <el-icon><el-icon-document /></el-icon>
          <span>内容管理</span>
        </template>
        <el-menu-item index="/column">栏目管理</el-menu-item>
        <el-menu-item index="/news">资讯管理</el-menu-item>
        <el-menu-item index="/audit">审核列表</el-menu-item>
        <el-menu-item index="/advertisement">广告管理</el-menu-item>
      </el-sub-menu>

      <el-sub-menu index="5">
        <template #title>
          <el-icon><el-icon-data-line /></el-icon>
          <span>数据统计</span>
        </template>
        <el-menu-item index="/userCount">用户统计</el-menu-item>
        <el-menu-item index="/statistics/appointment">挂号统计</el-menu-item>
        <el-menu-item index="/statistics/physical-examination">体检统计</el-menu-item>
        <el-menu-item index="/statistics/consultation">问诊统计</el-menu-item>
        <el-menu-item index="/productStats">销售统计</el-menu-item>
      </el-sub-menu>

      <el-sub-menu index="6">
        <template #title>
          <el-icon><el-icon-setting /></el-icon>
          <span>系统管理</span>
        </template>
        <el-menu-item index="/userList">用户列表</el-menu-item>
        <el-menu-item index="/roleList">角色管理</el-menu-item>
        <el-menu-item index="/permission">权限管理</el-menu-item>
        <el-menu-item index="/accountList">账号管理</el-menu-item>
        <el-menu-item  index="/bannedList">封禁管理</el-menu-item>
        <el-menu-item index="/logList">操作日志</el-menu-item>
      </el-sub-menu>

      <el-sub-menu v-if="hasPermission('system:testShow')" index="6">
        <template #title>
          <el-icon><el-icon-setting /></el-icon>
          <span>测试权限显示</span>
        </template>
        <el-menu-item index="/userList">用户列表</el-menu-item>
        <el-menu-item index="/roleList">角色管理</el-menu-item>
        <el-menu-item index="/permission">权限管理</el-menu-item>
        <el-menu-item index="/accountList">账号管理</el-menu-item>
        <el-menu-item index="/bannedList">封禁管理</el-menu-item>

      </el-sub-menu>
    </el-menu>
  </el-aside>
</template>

<style scoped>
.side-bar {
  background-color: #001529;
  height: 100vh;
}

.el-menu-vertical {
  border-right: none;
}
</style>